﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Newtonsoft.Json;
using ScFramework.Core;
[Serializable]
public class TestSerializableValue
{
    [SerializeField]
    public string type;
    [SerializeField]
    public string value;
    [JsonIgnore]
    public Type ValueType
    {

        get => ValueUtil.Get(type).ValueType;
        set => type = ValueUtil.Get(value).TypeName;
    }
    [JsonIgnore]
    public object Value
    {
        
        get => typeof(JsonUtil).GetMethod("Deserialize").MakeGenericMethod(ValueType).Invoke(null,new object[] {value});
        set
        {
            this.value = JsonUtil.Serialize(value);
        }
    }
    public TestSerializableValue() { }
    public TestSerializableValue(object v)
    {
        ValueType = v.GetType();

        if(v.GetType() != ValueType)
        {
            Debug.Log(type+ " "+ Type.GetType(type));
        }
        Value = v;
    }
}
[Serializable]
public class PrefabValuePair
{
    [SerializeField]
    public UInt16 ID;
    [SerializeField]
    public TestSerializableValue ValuePair;

}
